/*********************************************************************************
  *Copyright(C),2015-2020,
  *TUYA
  *www.tuya.comm
  *FileName:    tuya_ipc_dp_utils.h
  *
  *Do not modify any of the contents of this file at will.
  Please contact the Product Manager if you need to modify it! !
  * File Description：
  * 1. DP point definition
  * 2. DP point API definition
**********************************************************************************/

#ifndef _TUYA_IPC_DP_UTILS_H
#define _TUYA_IPC_DP_UTILS_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stdio.h>
#include <string.h>
#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include "cJSON.h"
#include "tuya_ipc_api.h"
#include "tuya_cloud_types.h"
#include "tuya_cloud_com_defs.h"
#include "tuya_com_dp_id_info.h"
#include "InCommon.h"
#include "InPerUart.h"

#if CMAKE_SUPPORT_STEP_MOTOR
#include "InPerSteppingMotor.h"
#endif

#if CMAKE_SUPPORT_STEEP_ENGINE
#include "InPerSteeringEngine.h"
#endif

#if 0
/* Exit SD card, BOOL type, true means it has been exited, false means it has not exited */
-2002: No SD card, -2003: SD card error. Positive number is formatting progress */
/* PTZ rotation stops, BOOL type*/
#define TUYA_DP_PTZ_STOP                        116
/*PTZ self-check switch, 0 means off, 1 means on, default value is off*/
#define TUYA_DP_PTZ_CHECK                       132
#endif

/* Report the latest status of all local DP points*/
VOID IPC_APP_upload_all_status(VOID);
VOID async_respone_dp_value(BYTE_T dp_id, INT_T val);
VOID respone_dp_value(BYTE_T dp_id, INT_T val);
VOID respone_dp_fault(BYTE_T dp_id, INT_T val);
VOID respone_dp_bool(BYTE_T dp_id, BOOL_T true_false);
VOID respone_dp_enum(BYTE_T dp_id, CHAR_T *p_val_enum);
INT_T respone_dp_str(BYTE_T dp_id, CHAR_T *p_val_str);
INT_T respone_dp_raw(BYTE_T dp_id, UCHAR_T *p_raw,INT_T len);

#ifdef TUYA_DP_SD_FORMAT_STATUS_ONLY_GET
/* SD card formatting progress report*/
VOID IPC_APP_report_sd_format_status(INT_T status);
#endif

#ifdef TUYA_DP_SD_STATUS_ONLY_GET
/*When the SD card changes (plug and unplug), call this API to notify to APP*/
VOID IPC_APP_report_sd_status_changed(INT_T status);
#endif

#ifdef TUYA_DP_SD_STORAGE_ONLY_GET
/* After formatting, call this API to report the storage capacity. */
VOID IPC_APP_report_sd_storage();
#endif

/* basic API */
VOID IPC_APP_handle_dp_cmd_objs(IN CONST TY_RECV_OBJ_DP_S *dp_rev);
/* API */
VOID IPC_APP_handle_dp_query_objs(IN CONST TY_DP_QUERY_S *dp_query);

VOID IPC_APP_handle_raw_dp_cmd_objs(IN CONST TY_RECV_RAW_DP_S *dp_rev);

#if defined(TUYA_EXTEND_DEVELOP)
OPERATE_RET APP_DP_VALUE_CMD_PROC(IN CONST INT_T dp_id, IN CONST INT_T dp_value,OUT  INT_T * dp_report_value);
OPERATE_RET APP_DP_BOOL_CMD_PROC(IN CONST INT_T dp_id, IN CONST BOOL_T dp_value,OUT  BOOL_T * dp_report_value );
OPERATE_RET APP_DP_STR_CMD_PROC(IN CONST INT_T dp_id, IN CONST CHAR_T *dp_value,OUT  CHAR_T * dp_report_value);
OPERATE_RET APP_DP_ENUM_CMD_PROC(IN CONST INT_T dp_id, IN CONST UINT_T dp_value,OUT  CHAR_T * dp_report_value);
OPERATE_RET APP_DP_BITMAP_CMD_PROC(IN CONST INT_T dp_id, IN CONST UINT_T dp_value,OUT  UINT_T * dp_report_value);
#endif

#ifdef __cplusplus
}
#endif

#endif  /*_TUYA_IPC_DP_UTILS_H*/
